package com.ruoyi.funding.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.funding.domain.FundingAllocationCopy;
import com.ruoyi.funding.service.IFundingAllocationCopyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 资金拨款记录历史Controller
 * 
 * @author gw
 * @date 2025-01-15
 */
@RestController
@RequestMapping("/copy")
public class FundingAllocationCopyController extends BaseController
{
    @Autowired
    private IFundingAllocationCopyService fundingAllocationCopyService;

    /**
     * 查询资金拨款记录历史列表
     */
    @RequiresPermissions("funding:copy:list")
    @GetMapping("/list")
    public TableDataInfo list(FundingAllocationCopy fundingAllocationCopy)
    {
        startPage();
        List<FundingAllocationCopy> list = fundingAllocationCopyService.selectFundingAllocationCopyList(fundingAllocationCopy);
        return getDataTable(list);
    }

    /**
     * 导出资金拨款记录历史列表
     */
    @RequiresPermissions("funding:copy:export")
    @Log(title = "资金拨款记录历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FundingAllocationCopy fundingAllocationCopy)
    {
        List<FundingAllocationCopy> list = fundingAllocationCopyService.selectFundingAllocationCopyList(fundingAllocationCopy);
        ExcelUtil<FundingAllocationCopy> util = new ExcelUtil<FundingAllocationCopy>(FundingAllocationCopy.class);
        util.exportExcel(response, list, "资金拨款记录历史数据");
    }

    /**
     * 获取资金拨款记录历史详细信息
     */
    @RequiresPermissions("funding:copy:query")
    @GetMapping(value = "/{historyId}")
    public AjaxResult getInfo(@PathVariable("historyId") Long historyId)
    {
        return success(fundingAllocationCopyService.selectFundingAllocationCopyByHistoryId(historyId));
    }

    /**
     * 新增资金拨款记录历史
     */
    @RequiresPermissions("funding:copy:add")
    @Log(title = "资金拨款记录历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FundingAllocationCopy fundingAllocationCopy)
    {
        return toAjax(fundingAllocationCopyService.insertFundingAllocationCopy(fundingAllocationCopy));
    }

    /**
     * 修改资金拨款记录历史
     */
    @RequiresPermissions("funding:copy:edit")
    @Log(title = "资金拨款记录历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FundingAllocationCopy fundingAllocationCopy)
    {
        return toAjax(fundingAllocationCopyService.updateFundingAllocationCopy(fundingAllocationCopy));
    }

    /**
     * 删除资金拨款记录历史
     */
    @RequiresPermissions("funding:copy:remove")
    @Log(title = "资金拨款记录历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{historyIds}")
    public AjaxResult remove(@PathVariable Long[] historyIds)
    {
        return toAjax(fundingAllocationCopyService.deleteFundingAllocationCopyByHistoryIds(historyIds));
    }
}
